import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/kq_screen_util.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:kq_flutter_widgets/config/kq_global.dart';
import 'package:kq_flutter_widgets/resources/kq_theme_colors.dart';
import 'package:kq_flutter_widgets/theme/kq_theme_manager.dart';
import 'package:kq_flutter_widgets/utils/dialog_util.dart';
import 'package:kq_flutter_widgets/utils/native/scan_native_util.dart';
import 'package:kq_flutter_core_widget/utils/toast_util.dart';
import 'package:kq_flutter_widgets/widgets/bottomTabBar/kq_bottom_tab_bar.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_bottom_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_head_button.dart';
import 'package:kq_flutter_core_widget/widgets/button/kq_ink_well.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_outline_button.dart';
import 'package:kq_flutter_widgets/widgets/executor/chain_executor.dart';
import 'package:kq_flutter_widgets/widgets/checkbox/kq_checkbox.dart';
import 'package:kq_flutter_widgets/widgets/chooseItemView/kq_choose_item_view.dart';
import 'package:kq_flutter_widgets/widgets/circle/kq_circle_view.dart';
import 'package:kq_flutter_widgets/widgets/detailsItemView/kq_details_item_view.dart';
import 'package:kq_flutter_widgets/widgets/formItem/entity/kq_form_entity.dart';
import 'package:kq_flutter_widgets/widgets/formItem/kq_edit_more_view.dart';
import 'package:kq_flutter_widgets/widgets/formItem/kq_header_item_view.dart';
import 'package:kq_flutter_widgets/widgets/formItem/kq_more_auto_view.dart';
import 'package:kq_flutter_core_widget/widgets/image/kq_image.dart';
import 'package:kq_flutter_core_widget/widgets/imageBox/kq_image_box.dart';
import 'package:kq_flutter_widgets/widgets/listener/object_watcher/watchable_object.dart';
import 'package:kq_flutter_widgets/widgets/listener/object_watcher/watcher.dart';
import 'package:kq_flutter_widgets/widgets/noticeView/kq_notice_view.dart';
import 'package:kq_flutter_widgets/widgets/permission/kq_permission_view.dart';
import 'package:kq_flutter_widgets/widgets/progressbar/kq_dashboard_progress_bar.dart';
import 'package:kq_flutter_widgets/widgets/progressbar/kq_horizontal_progress_bar.dart';
import 'package:kq_flutter_widgets/widgets/progressbar/ring_progress_bar.dart';
import 'package:kq_flutter_widgets/widgets/rainbowBar/kq_rainbow_bar.dart';
import 'package:kq_flutter_widgets/widgets/rainbowBar/kq_rainbow_value.dart';
import 'package:kq_flutter_widgets/widgets/searchBar/kq_search_bar.dart';
import 'package:kq_flutter_widgets/widgets/selectTag/kq_select_tag.dart';
import 'package:kq_flutter_widgets/widgets/specialView/kq_special_view.dart';
import 'package:kq_flutter_widgets/widgets/steps/kq_horizontal_steps.dart';
import 'package:kq_flutter_widgets/widgets/tabView/kq_tab_view.dart';
import 'package:kq_flutter_widgets/widgets/tagView/kq_icon_tag.dart';
import 'package:kq_flutter_widgets/widgets/tagView/kq_number_tag_view.dart';
import 'package:kq_flutter_widgets/widgets/tagView/kq_tag_view.dart';
import 'package:kq_flutter_widgets/widgets/textFiled/kq_textfiled.dart';
import 'package:kq_flutter_widgets/widgets/tip/kq_tip.dart';
import 'package:kq_flutter_widgets/widgets/titleBar/kq_title_bar.dart';
import 'package:kq_flutter_widgets/widgets/seekbar/kq_seek_bar.dart';
import 'package:kq_flutter_widgets/widgets/password/kq_password_view.dart';
import 'package:kq_flutter_widgets/widgets/seekbar/seek_bar.dart';

import '../../resources/Images.dart';
import '../../resources/kq_images.dart';
import '../../router/route_map.dart';

/// 自定义控件演示页面
class CustomViewsPage extends StatefulWidget {
  const CustomViewsPage({super.key});

  @override
  State<StatefulWidget> createState() {
    return CustomViewsPageState();
  }
}

class CustomViewsPageState extends State<CustomViewsPage> {
  final GlobalKey<CustomViewsPageState> key = GlobalKey();
  final GlobalKey<KqRainbowBarState> keyRainbowBar =
      GlobalKey<KqRainbowBarState>();
  final GlobalKey<KqTipState> keyKqTip1 = GlobalKey<KqTipState>();
  final GlobalKey<KqTipState> keyKqTip2 = GlobalKey<KqTipState>();
  final GlobalKey<KqTipState> keyKqTip3 = GlobalKey<KqTipState>();

  TitleBarShowMode titleMode = TitleBarShowMode.normal;

  var checked = false;

  var titles = ['One', 'Two', 'Three', 'Four', 'Five', 'Six'];
  var _selectedIndex = 0;
  int current = 0;
  List steps = [
    {'title': '咨询单填写', 'state': '2'},
    {'title': '提交询价', 'state': '1'},
    {'title': '办事处回复', 'state': '0'}
  ];
  int currentIndex = 1;

  String testText = "";

  KqFormEntity moreEntity = KqFormEntity(
      itemType: ItemType.custom,
      title: '复合板',
      hint: '请输入',
      mustInput: true,
      showUnit: false);
  KqFormEntity unitEntity = KqFormEntity(
      itemType: ItemType.custom,
      title: '复合板',
      hint: '请输入',
      mustInput: true,
      showUnit: true);

  KqFormEntity spec = KqFormEntity(
      itemType: ItemType.custom,
      mustInput: true,
      editable: true,
      // extraData: [
      //   KqFormBaseEntity(valueForShow: 'dsff'),
      //   KqFormBaseEntity(valueForShow: 'ewwewedd'),
      // ],
      title: '模仁');

  String _newValue = "111";

  @override
  Widget build(BuildContext context) {
    ChainExecutor executor = ChainExecutor();
    Future.delayed(Duration(seconds: 20), () {
      executor
        ..onOpen(() {
          print("start");
        })
        ..onClose(() {
          print("close");
        })
        ..add(Chain((chain, data) {
          Future.delayed(const Duration(seconds: 2), () {
            print(">>>>>>>>>>>>1");
            chain.finish();
          });
          return "我是第一个Chain";
        }))
        ..add(Chain((chain, data) {
          print("我是上一个Chain的值：$data");
          print(">>>>>>>>>>>>2");
          chain.finish();
          return "我是第二个Chain";
        }))
        ..add(Chain((chain, data) {
          print("我是上一个Chain的值：$data");
          print(">>>>>>>>>>>>3");
          print("我没有调finish，所以我不会结束3");
          return "我是第三个Chain"; //该Chain没有主动调用finish(),如果别处有调next(data:"")并传递了data，则这里的返回值不会生效，会以next传递的data为准
        }))
        ..add(Chain((chain, data) {
          print("我是主动调用next传来的值：$data");
          print(">>>>>>>>>>>>4");
          print("我没有调finish，所以我不会结束4");
        }))
        ..execute();
    });
    Future.delayed(const Duration(seconds: 25), () {
      print("我是主动调用下一个chain");
      executor.next();
      //ChainExecutor().next(data: "我是主动调用下一个Chain传来的值，嘿嘿");//此处的data会传递给下一个Chain，上一个Chain传递来的值则会丢弃
    });
    Future.delayed(const Duration(seconds: 30), () {
      print("我是主动结束调用进程");
      executor.stop();
    });

    ///场景：检查[test11][test12][test13]均不为空时做一些事情，例如提交按钮变成可点击
    String? test11;
    String? test12;
    int? test13;

    ///当需要检查[test11][test12][test13]是否全部有值时需要这么做。
    ///1.给[test11][test12][test13]设置监听，或者在他们赋值的时候每次调用2检查。
    ///2.检查三个值的状态
    if (test11 != null && test12 != null && test12 != null) {
      ///print [test11][test12][test13]均不为空。
    }

    ///使用[WatchableObject]配合[Watcher]监测
    ///1.只需要把String、int、bool、等对象用[WatchableObject]代替。
    WatchableObject test1 = WatchableObject();
    WatchableObject test2 = WatchableObject();
    WatchableObject test3 = WatchableObject();

    ///2.使用[Watcher]单例绑定对象。
    Watcher().bindObject([test1, test2, test3]);

    ///3.检查回调
    Watcher().check((allCheck) {
      print("?????????????????????=$allCheck");
    });

    ///4.模拟不同时间赋值
    Future.delayed(Duration(seconds: 3), () {
      test1.setValue("1");
    });
    Future.delayed(Duration(seconds: 6), () {
      test2.setValue("123");
    });
    Future.delayed(Duration(seconds: 8), () {
      test3.setValue(123);
    });

    return GestureDetector(
      onTap: () {
        keyRainbowBar.currentState?.closeTips();
        keyKqTip1.currentState?.close();
        keyKqTip2.currentState?.close();
        keyKqTip3.currentState?.close();
      },
      child: Scaffold(
        appBar: KqHeadBar(
            headTitle: "自定义控件演示",
            back: () => Get.back(),
            showMode: titleMode,
            onCancelSearch: () {
              setState(() {
                titleMode = TitleBarShowMode.normal;
              });
            },
            onSearchSubmit: (value, state) => KqToast.showNormal(value),
            onSearchMonitor: (str) => KqToast.showNormal(str),
            onSearchCleared: () => KqToast.showNormal('清空'),
            actions: [
              KqHeadButton(
                buttonType: KqHeadButtonType.icon,
                widget: Icon(Icons.search,
                    size: 20.r, color: KqThemeColors.bgWhite),
                onTap: () {
                  setState(() {
                    titleMode = TitleBarShowMode.search;
                  });
                },
              ),
              KqHeadButton(
                buttonType: KqHeadButtonType.icon,
                widget: Icon(Icons.more_vert,
                    size: 20.r, color: KqThemeColors.bgWhite),
                menuData: [
                  KqPopMenuItemData(
                      title: "审核",
                      imageUrl: Images.demoEditor,
                      hasPermission: true),
                  KqPopMenuItemData(
                      title: "很长", imageUrl: Images.demoIcDelete28Black),
                ],
                onSelected: (position, entity) {
                  if (position == 0) {
                    RouteMap.pushTableDemo();
                  }
                },
              )
            ]),
        body: SingleChildScrollView(
          // padding: EdgeInsets.symmetric(horizontal: 20.r, vertical: 20.r),
          child: Column(
            children: [
              KqHeaderItemView(entity: KqFormEntity(title: 'KqTagView演示')),
              Padding(
                padding: EdgeInsets.symmetric(horizontal: 16.r),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    KqTagView(
                      text: '标签',
                      textColor: KqThemeColors.textYellow,
                      borderColor: KqThemeColors.textYellow,
                    ),
                    SizedBox(
                      width: 10.r,
                      height: 1.r,
                    ),
                    KqTagView(
                      text: '标签',
                      textColor: KqThemeColors.textGreen,
                      borderColor: KqThemeColors.textGreen,
                    ),
                    SizedBox(
                      width: 10.r,
                      height: 1.r,
                    ),
                    KqTagView(
                      text: '标签',
                      textColor: KqThemeColors.textRed,
                      borderColor: KqThemeColors.textRed,
                    ),
                    SizedBox(
                      width: 10.r,
                      height: 1.r,
                    ),
                    KqTagView(
                      text: '已挂起',
                      dashLine: true,
                      textColor: KqThemeColors.textYellow,
                      borderColor: KqThemeColors.textYellow,
                    ),
                    SizedBox(
                      width: 10.r,
                      height: 1.r,
                    ),
                    KqTagView(
                      text: '带背景很长',
                      dashLine: true,
                      backgroundColor: KqThemeColors.textGreen,
                      textColor: KqThemeColors.textLightBlue,
                      borderColor: KqThemeColors.bgWhite,
                    ),
                  ],
                ),
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: "KqImage 演示")),
              KqImageBox(urls: [
                ImageUrl(
                    imageType: ImageType.oss,
                    url:
                        '10102/mainStation/1b8b72bf-5325-45cb-9f05-b2efb4e9508d&2.9.0.jpg')
              ]),
              Row(
                children: [
                  KqImage.oss(
                    radius: 10.r,
                    url:
                        '10102/mainStation/1b8b72bf-5325-45cb-9f05-b2efb4e9508d&2.9.0.jpg',
                    width: 100.r,
                    height: 100.r,
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: 10.r,
                    height: 10.r,
                  ),
                  KqImage.http(
                    radius: 10.r,
                    url:
                        'https://img1.baidu.com/it/u=2527732730,3137228782&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1677949200&t=615911fe42ee6d10a288bba35771b868',
                    width: 100.r,
                    height: 100.r,
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: 10.r,
                    height: 10.r,
                  ),
                  KqImage.assets(
                    url: Images.homeIcTouxiang,
                    width: 100.r,
                    height: 100.r,
                    fit: BoxFit.cover,
                  )
                ],
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'IconTagView演示')),
              Row(
                children: [
                  KqIconTagView(
                    text: '已生产',
                    iconPath: Images.taskIcChanxian12Black,
                    textColor: KqThemeColors.textGreen,
                    backgroundColor: KqThemeColors.textRed,
                    // witdh: 100.r,
                  ),
                  SizedBox(
                    width: 10.r,
                    height: 1.r,
                  ),
                  KqIconTagView(
                    text: '生产中',
                    iconPath: Images.taskIcZhuangtai12Black,
                    backgroundColor: KqThemeColors.textYellow,
                    viewType: 2,
                  ),
                  SizedBox(
                    width: 10.r,
                    height: 1.r,
                  ),
                  KqIconTagView(
                    text: '水电费水电费撒发的发',
                    iconPath: Images.taskIcChanxian12Black,
                    textColor: KqThemeColors.textGreen,
                    // backgroundColor: KqThemeColors.textRed,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    maxLines: 2,
                    iconHeight: 20.r,
                    width: 80.r,
                  ),
                  SizedBox(
                    width: 10.r,
                    height: 1.r,
                  ),
                  KqIconTagView(
                    text: '水电费水电费撒发的发',
                    iconPath: Images.taskIcChanxian12Black,
                    backgroundColor: KqThemeColors.textYellow,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    leftText: '按时',
                    maxLines: 2,
                    viewType: 3,
                    iconWidth: 60.r,
                    textWidthType: TextWidthType.fix,
                    width: 130.r,
                  ),
                  //  SizedBox(
                  //   width: 10.r,
                  //   height: 1.r,
                  // ),
                  // IconTagView(
                  //   text: '水电费水电费撒发的发',
                  //   iconPath: Images.taskIcChanxian12Black,
                  //   textColor: KqThemeColors.textGreen,
                  //   backgroudColor: KqThemeColors.textRed,
                  //   maxLines: 2,
                  //   witdh: 100.r,
                  // ),
                ],
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqRainbowBar(彩虹条)演示')),
              KqRainbowBar(
                height: 24.r,
                key: keyRainbowBar,
                showTips: true,
                data: [
                  KqRainbowValue(
                      value: 20,
                      color: KqThemeColors.textGreen,
                      text: "工作\n2023-03-07 11:00 -> 2023-03-07 11:20"),
                  KqRainbowValue(
                      value: 20,
                      color: KqThemeColors.textRed,
                      text: "异常\n2023-03-07 11:20 -> 2023-03-07 11:40"),
                  KqRainbowValue(
                      value: 2,
                      color: KqThemeColors.textGreen,
                      text: "工作\n2023-03-07 11:40 -> 2023-03-07 11:42"),
                  KqRainbowValue(
                      value: 7,
                      color: KqThemeColors.text8C,
                      text: "离线\n2023-03-07 11:42 -> 2023-03-07 11:49"),
                  KqRainbowValue(
                      value: 5,
                      color: KqThemeColors.textGreen,
                      text: "工作\n2023-03-07 11:49 -> 2023-03-07 11:54"),
                  KqRainbowValue(
                      value: 10,
                      color: KqThemeColors.textYellow,
                      text: "空闲\n2023-03-07 11:54 -> 2023-03-07 12:04"),
                  KqRainbowValue(
                      value: 20,
                      color: Colors.white,
                      text: "无状态\n2023-03-07 12:04 -> 2023-03-07 12:24"),
                  KqRainbowValue(
                      value: 40,
                      color: KqThemeColors.text8C,
                      text: "离线\n2023-03-07 12:24 -> 2023-03-07 13:04"),
                  KqRainbowValue(
                      value: 10,
                      color: KqThemeColors.textYellow,
                      text: "空闲\n2023-03-07 13:04 -> 2023-03-07 13:14"),
                ],
                rainbowBarMoveListener: (position, dialogShowPositionLocal,
                    dialogShowPositionGlobal, value) {
                  KqToast.showNormal(position.toString());
                },
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqNoticeView公告栏演示')),
              const KqNoticeView(
                content: '这是一条公告，内容很长很长很长很长很长很长很长很长。',
              ),
              KqNoticeView(
                textHeight: 44.r,
                verticalPadding: 0,
                backgroundColor: KqThemeColors.textRed,
                noticeIcon: Container(),
                closable: false,
                richContent: RichText(
                    textAlign: TextAlign.end,
                    text: TextSpan(
                      children: [
                        TextSpan(text: "您有", style: TextStyle(fontSize: 13.sp)),
                        TextSpan(
                          text: "20",
                          style: TextStyle(fontSize: 20.sp),
                        ),
                        TextSpan(
                            text: "台设备已超期", style: TextStyle(fontSize: 13.sp)),
                        TextSpan(
                          text: "43",
                          style: TextStyle(fontSize: 20.sp),
                        ),
                        TextSpan(
                            text: "，为避免影响正常使用，请及时续费。",
                            style: TextStyle(fontSize: 13.sp)),
                      ],
                    )),
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqDetailsItemView 通用详情Item演示')),
              KqDetailsItemView(
                title: '标题',
                showMustInput: true,
                content: '内容内容内容内容内容',
                expandContentEnable: true,
                showRightArrow: true,
                onTaped: () {
                  KqToast.showNormal('111');
                },
              ),
              KqDetailsItemView(
                title: '标题',
                showMustInput: true,
                content:
                    '内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容',
                expandContentEnable: true,
                showRightArrow: true,
                onTaped: () {
                  KqToast.showNormal('111');
                },
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqDragGridView 拖拽排序演示')),
              Row(
                children: [
                  KqOutlineButton(
                    title: '去演示（网格）',
                    onTap: () => RouteMap.pushDragGridViewDemo(),
                  ),
                  KqOutlineButton(
                    title: '去演示（列表）',
                    onTap: () => RouteMap.pushDragListViewDemoPage(),
                  ),
                  KqOutlineButton(
                    title: '去演示（仿抽屉）',
                    onTap: () => RouteMap.pushDragDrawerDemo(),
                  )
                ],
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'KqTabBar 演示')),
              Row(
                children: [
                  KqOutlineButton(
                    title: '去演示',
                    onTap: () {
                      RouteMap.pushTabBarDemo();
                    },
                  )
                ],
              ),
              SizedBox(
                width: 1.r,
                height: 10.r,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'KqToast 演示')),
              Row(
                children: [
                  KqOutlineButton(
                    title: '普通Toast',
                    onTap: () {
                      KqToast.showNormal('这是一个普通的吐司');
                    },
                  ),
                  SizedBox(
                    width: 10.r,
                  ),
                  KqOutlineButton(
                    title: '成功Toast',
                    onTap: () {
                      KqToast.showSuccess('这是一个成功的吐司');
                    },
                  )
                ],
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(
                      title: 'KqSectionGridView，KqSectionListView分区演示')),
              Row(
                children: [
                  KqOutlineButton(
                    title: '分区网格',
                    onTap: () => RouteMap.pusSectionGridViewDemo(),
                  ),
                  KqOutlineButton(
                      title: '分区列表',
                      onTap: () => RouteMap.pusSectionListView()),
                ],
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'ChartView 图表演示')),
              Row(
                children: [
                  KqOutlineButton(
                    title: '曲线折线图',
                    onTap: () => RouteMap.pushKqChartLineDemo(),
                  ),
                  KqOutlineButton(
                    title: '扇形分布图',
                    onTap: () => RouteMap.pushKqChartPieDemo(),
                  )
                ],
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqNumberTagView 数字角标演示')),
              Row(
                children: [
                  KqNumberTagView(
                    number: 1,
                    backgroundColor: KqThemeColors.bgWhite,
                    borderColor: KqThemeColors.textRed,
                    borderWidth: 1,
                    textColor: KqThemeColors.textRed,
                  ),
                  SizedBox(
                    width: 5.r,
                    height: 1.r,
                  ),
                  KqNumberTagView(
                    number: 10,
                    max: 99,
                  ),
                  SizedBox(
                    width: 5.r,
                    height: 1.r,
                  ),
                  KqNumberTagView(
                    number: 1000,
                    backgroundColor: KqThemeColors.textLightBlue,
                  ),
                  SizedBox(
                    width: 5.r,
                    height: 1.r,
                  ),
                  KqNumberTagView(
                    number: 100,
                    max: 99,
                  ),
                ],
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'RingProgressBar 带倒计时环型进度条')),
              RingProgressBar(
                radius: 50,
                strokeWidth: 10,
                isShowText: true,
                maxProgress: 10,
                callback: () {
                  print("callback回调了");
                },
              ),
              KqHeaderItemView(
                  entity:
                      KqFormEntity(title: 'KqHorizontalProgressBar 二级水平进度条')),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqHorizontalProgressBar(
                height: 12.r,
                progress: 80,
                secondProgress: 50,
                radius: 3.r,
                enableSecondProgress: true,
                secondProgressShape: SecondProgressShape.roundRect,
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqHorizontalProgressBar(
                height: 12.r,
                progress: 60,
                secondProgress: 30,
                radius: 0,
                enableSecondProgress: true,
                secondProgressShape: SecondProgressShape.roundRect,
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqHorizontalProgressBar(
                height: 12.r,
                progress: 50,
                secondProgress: 30,
                radius: 10.r,
                enableSecondProgress: true,
                secondProgressShape: SecondProgressShape.point,
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqTextFiled 固定高度演示')),
              Container(
                width: context.width,
                height: 120.r,
                color: KqThemeColors.lineColor,
                padding: EdgeInsets.all(14.r),
                child: KqTextFiled(
                  useParentHeight: true,
                  multiline: true,
                  newValue: _newValue,
                ),
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'KqSearchBar 演示')),
              Container(
                width: context.width,
                color: KqThemeColors.lineColor,
                child: KqSearchBar(
                  onSubmit: (value, state) => KqToast.showNormal(value),
                ),
              ),
              SizedBox(
                width: 1,
                height: 5.r,
              ),
              KqSearchBar(
                editable: false,
                enablePDAScan: true,
                autoFocusBorder: true,
                onSubmit: (value, state) => KqToast.showNormal(value),
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqSeekBar 带两个按钮的SeekBar')),
              KqSeekBar(
                isTwoSeekBar: true,
                callback: (int one, int two) {
                  print("one=$one;two=$two");
                },
              ),
              SizedBox(
                height: 2.r,
              ),
              KqSeekBar(
                isTwoSeekBar: true,
                showSeekBarText: true,
                height: 32.r,
                progressHeight: 6.r,
                callback: (int one, int two) {
                  print("one=$one;two=$two");
                },
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqSeekBar 带一个按钮的SeekBar')),
              const KqSeekBar(),
              KqHeaderItemView(
                  entity: KqFormEntity(
                      title: 'SeekBar 基础SeekBar，可自定义按钮，可设置高度，可格式化数据等')),
              SeekBar(
                callback: (a1, a2) {
                  print(a1);
                },
                max: 50.5566776,
                numberFormat: NumberFormat("#0.0#"),
                oneSeekWidget: KqImage.assets(
                  url: KqImages.materialIcDelete16Red,
                  width: 44.r,
                  height: 44.r,
                ),
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '二维码扫描')),
              KqOutlineButton(
                title: '开始扫描',
                onTap: () {
                  ScanNativeUtil.scanWithCallback(
                    showLightButton: true,
                    callback: (result) {
                      if (!result.isCancel) {
                        KqToast.showNormal(result.content);
                      }
                    },
                  );
                },
              ),
              const KqTabView(
                titles: ['删除Normal', '提交Normal'],
                colorTypes: [ColorType.lineGrey, ColorType.fillBlue],
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              const KqTabView(
                titles: ['保存Nomal', '提交Normal'],
                colorTypes: [ColorType.lineBlue, ColorType.fillBlue],
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqTabView(
                tabIndexBlock: (index, disable) {
                  List<DropdownMenuItem> getddd = [];
                  final DropdownMenuItem item1 = DropdownMenuItem(
                    child: Text('背景'),
                    value: '背景',
                  );
                  final DropdownMenuItem item2 = DropdownMenuItem(
                    child: Text('面试南昌分'),
                    value: '面试南昌分',
                  );
                  final DropdownMenuItem item3 = DropdownMenuItem(
                    child: Text('vehviuoerfb'),
                    value: 'vehviuoerfb',
                  );
                  getddd.add(item1);
                  getddd.add(item2);
                  getddd.add(item3);

                  KqDialog.showCustomDialog(
                      title: '挂起原因',
                      customWidget: Container(
                        padding: EdgeInsets.symmetric(horizontal: 16.r),
                        child: Column(
                          children: [
                            DropdownButtonHideUnderline(
                                child: Container(
                              height: 40.r,
                              padding: EdgeInsets.symmetric(horizontal: 12.r),
                              decoration: BoxDecoration(
                                  borderRadius:
                                      BorderRadius.all(Radius.circular(2)),
                                  border: Border.all(
                                      width: 1, color: KqThemeColors.bgD)),
                              child: DropdownButton(
                                  isDense: true,
                                  isExpanded: true,
                                  value: '面试南昌分',
                                  // selectedItemBuilder: (context) {
                                  //   return [
                                  //     const Text(
                                  //       '面试南昌分',
                                  //       maxLines: null,
                                  //       overflow: TextOverflow.ellipsis,
                                  //     )
                                  //   ];
                                  // },
                                  items: getddd,
                                  style: TextStyle(color: KqThemeColors.text26),
                                  onChanged: ((value) {})),
                            )),
                            Padding(
                              padding: EdgeInsets.symmetric(vertical: 10.r),
                              child: KqTextFiled(
                                fixedHeight: 100.r,
                                fontSize: 16.sp,
                                useParentHeight: true,
                                maxLines: null,
                                outerPadding: EdgeInsets.symmetric(
                                    horizontal: 12.r, vertical: 8.r),
                                placeHolder: '请补充说明',
                                outerDecoration: BoxDecoration(
                                    borderRadius:
                                        BorderRadius.all(Radius.circular(2.r)),
                                    border:
                                        Border.all(color: KqThemeColors.bgD)),
                              ),
                            )
                          ],
                        ),
                      ),
                      customBtnWidget: (context, onCancel) {
                        return Row(
                          children: [
                            Expanded(
                                child: KqInkWell(
                              onTap: () {
                                Navigator.pop(context);
                                onCancel?.call();
                              },
                              child: Container(
                                alignment: Alignment.center,
                                width: double.infinity,
                                height: 48.r,
                                child: Text(
                                  "自定义按钮",
                                  style: TextStyle(
                                      fontSize: 16.sp,
                                      color: KqThemeManager.instance
                                              .getConfig()
                                              .dialogConfig
                                              .mainBtnColor ??
                                          KqThemeColors.textLightBlue),
                                ),
                              ),
                            ))
                          ],
                        );
                      });
                },
                titles: const ['保存Disable', '提交Disable'],
                colorTypes: const [ColorType.lineBlue, ColorType.fillBlue],
              ),
              SizedBox(
                width: 5.r,
                height: 4.r,
              ),
              KqSpecialView(
                  onTap: (entity) {
                    KqDialog.showInputDialog('title', onConfirm: ((value) {
                      List<KqFormBaseEntity> items = [];
                      if (entity.extraData != null &&
                          (entity.extraData as List).isNotEmpty) {
                        items = entity.extraData;
                      }
                      items.add(KqFormBaseEntity(valueForShow: value));
                      setState(() {
                        entity.extraData = items;
                      });
                    }));
                  },
                  entity: spec),
              KqSpecialView(
                  entity: KqFormEntity(
                      itemType: ItemType.custom,
                      mustInput: true,
                      editable: false,
                      valueForShow:
                          '能加分发你缝纫机ENFJ妇女节而那附近儿保附件二你姐夫可容纳副卡人,dsff,ewwewedd',
                      extraData: [
                        KqFormBaseEntity(
                            valueForShow: '能加分发你缝纫机ENFJ妇女节而那附近儿保附件二你姐夫可容纳副卡人'),
                        KqFormBaseEntity(valueForShow: 'dsff'),
                        KqFormBaseEntity(valueForShow: 'ewwewedd'),
                      ],
                      title: '模仁')),
              KqSpecialView(
                  isSeparate: true,
                  entity: KqFormEntity(
                      itemType: ItemType.custom,
                      mustInput: true,
                      editable: false,
                      valueForShow:
                          '能加分发你缝纫机ENFJ妇女节而那附近儿保附件二你姐夫可容纳副卡人,dsff,ewwewedd',
                      extraData: [
                        KqFormBaseEntity(
                            valueForShow: '能加分发你缝纫机ENFJ妇女节而那附近儿保附件二你姐夫可容纳副卡人'),
                        KqFormBaseEntity(valueForShow: 'dsff'),
                        KqFormBaseEntity(valueForShow: 'ewwewedd'),
                      ],
                      title: '模仁')),
              KqMoreAutoView(
                data: moreEntity,
                didSelect: (entity) {
                  setState(() {
                    entity.title = '111';
                  });
                },
              ),
              KqMoreAutoView(data: unitEntity),
              KqHorizontalSteps(
                controller: KqStepsController(
                    currentIndex: currentIndex,
                    steps: steps.map((e) {
                      return KqStep(
                        stepContentText: e['title'],
                      );
                    }).toList()),
                callBack: (index, step) {
                  setState(() {
                    currentIndex = index;
                  });
                },
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(
                      title: 'KqTextFiled功能扩展，可监控TextFiled的输入停顿演示')),
              const Text("请连在下面的输入框续输入然后停顿："),
              KqTextFiled(
                onMonitor: (str) {
                  setState(() {
                    testText = "暂停输入，值：$str";
                  });
                },
              ),
              Text(testText),
              KqHeaderItemView(
                  entity:
                      KqFormEntity(title: 'KqDashboardProgressBar 驾驶舱进度条演示')),
              const Row(
                children: [
                  Expanded(
                    child: SizedBox(
                        height: 150,
                        width: 150,
                        child: KqDashboardProgressBar(
                          centerText: "8000000000000000",
                          centerTextUnit: "%",
                          bottomText: "底部文字",
                          sweepScale: 500,
                        )),
                  ),
                  Expanded(
                      child: KqDashboardProgressBar(
                    centerText: "80",
                    centerTextUnit: "%",
                    bottomText: "底部文字",
                    sweepScale: 500,
                    width: 120,
                  ))
                ],
              ),
              KqEditMoreView(
                  entity: KqFormEntity(
                      title: '咨询',
                      mustInput: true,
                      backgroundColor: KqThemeColors.bgD,
                      paddingVertical: 10.r,
                      maxCharCount: 200,
                      counterText: null,
                      btnSpacing: 10.r)),
              SizedBox(
                width: 10.r,
                height: 20.r,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: 'checkbox演示')),
              const KqCheckBox(),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqChooseItemView 演示')),
              KqChooseItemView(
                title: "左边显示checkBox",
                direction: CheckBoxDirection.left,
                onItemTap: (checked) {
                  KqToast.showNormal("checked:$checked");
                },
              ),
              KqChooseItemView(
                title: "右边边显示checkBox",
                direction: CheckBoxDirection.right,
                disabled: true,
                isChecked: true,
                onItemTap: (checked) {
                  KqToast.showNormal("checked:$checked");
                },
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: '权限KqPermissionView 演示')),
              KqPermissionView(
                hasPermission: false,
                child: KqBottomButton(
                  title: '无权限子view不可用-请点击',
                  onTap: (disabled) {
                    print("我是子view");
                    KqToast.showNormal("我是子view");
                  },
                ),
              ),
              KqPermissionView(
                hasPermission: false,
                noPermissionEnable: true,
                child: KqBottomButton(
                  title: '无权限子view可用-请点击',
                  onTap: (disabled) {
                    print("我是子view");
                    KqToast.showNormal("我是子view");
                  },
                ),
              ),
              KqPermissionView(
                child: KqBottomButton(
                  title: '有权限子view可用-请点击',
                  onTap: (disabled) {
                    print("我是子view");
                    KqToast.showNormal("我是子view");
                  },
                ),
              ),
              KqHeaderItemView(
                  entity: KqFormEntity(title: 'KqSelectTag 选择切换的长条(均分|滚动|换行)')),
              KqHeaderItemView(entity: KqFormEntity(title: '均分')),
              const KqSelectTag(
                tagList: ["选项内容", "选项内容", "选项内容"],
                mode: KqSelectTagMode.share,
                initChoose: false,
              ),
              const KqSelectTag(
                tagList: ["选项内容", "选项内", "选项", "选项内容"],
                mode: KqSelectTagMode.share,
                initChoose: false,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '滚动')),
              const KqSelectTag(
                tagList: [
                  "当班",
                  "上一班",
                  "1天",
                  "7天",
                  "自定义",
                  "当班",
                  "上一班",
                  "1天",
                  "7天",
                  "自定义"
                ],
                mode: KqSelectTagMode.scroll,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '换行')),
              KqSelectTag(
                tagList: const [
                  "当班",
                  "上一班",
                  "1天",
                  "7天",
                  "自定义",
                  "当班",
                  "上一班",
                  "1天",
                  "7天",
                  "自定义项aaaa"
                ],
                wrapAlignment: WrapAlignment.start,
                spacing: 15.r,
                mode: KqSelectTagMode.wrap,
                itemConstraints: BoxConstraints(minWidth: 64.r),
                itemBoxBorder: (index) {
                  return Border.all(color: KqThemeColors.textLightBlue);
                },
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '智能模式，自动切换滚动和均分')),
              const KqSelectTag(
                tagList: [
                  "昨天",
                  "今天",
                  "明天",
                  "每一天",
                ],
                mode: KqSelectTagMode.smart,
              ),
              const KqSelectTag(
                tagList: [
                  "Yesterday",
                  "Today",
                  "tomorrow",
                  "everyday!!!",
                ],
                mode: KqSelectTagMode.smart,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '自定义项')),
              KqSelectTag(
                tagList: [
                  "当班",
                  "上一班",
                  "1天",
                ],
                initChoose: false,
                mode: KqSelectTagMode.share,
                customItem: (int i, int? position, String text) {
                  return Container(
                    decoration: BoxDecoration(
                      color: position != null && position == i
                          ? KqThemeColors.textLightBlue
                          : KqThemeColors.textWhite,
                    ),
                    padding:
                        EdgeInsets.symmetric(horizontal: 20.r, vertical: 4.r),
                    child: Text(
                      text,
                      style: TextStyle(
                          fontSize: 12.sp,
                          color: position != null && position == i
                              ? KqThemeColors.textWhite
                              : KqThemeColors.text26),
                      textAlign: TextAlign.center,
                    ),
                  );
                },
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '纯文本')),
              const KqSelectTag.text(
                tagList: [
                  "昨天",
                  "今天",
                  "明天",
                  "每一天",
                  "昨天",
                  "今天",
                  "明天",
                  "每一天",
                ],
                mode: KqSelectTagMode.scroll,
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '气泡 KqTip')),
              Row(
                children: [
                  SizedBox(width: 16.r),
                  KqTip(
                    "设备利用率=工作时间/自然时间**********************************************************************************************",
                    key: keyKqTip1,
                    tipsTextAlign: TextAlign.start,
                    child: Image.asset(
                      Images.demoIcZhushi,
                      width: 12.r,
                      height: 12.r,
                    ),
                  ),
                  Expanded(
                    child: KqTip(
                      "设备利用率=工作时间/自然时间",
                      key: keyKqTip2,
                      child: Image.asset(
                        Images.demoIcZhushi,
                        width: 12.r,
                        height: 12.r,
                      ),
                    ),
                  ),
                  KqTip(
                    "设备利用率=工作时间/自然时间",
                    key: keyKqTip3,
                    tipDirection: TipDirection.bottom,
                    child: Image.asset(
                      Images.demoIcZhushi,
                      width: 12.r,
                      height: 12.r,
                    ),
                  ),
                  SizedBox(width: 16.r),
                ],
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '圆角')),
              KqCircleView(
                text: '已认证',
                backgroundColor: KqThemeColors.bgBlack50,
                color: KqThemeColors.bgBlue,
                iconUrl: Images.demoEditor,
                iconSize: 12.r,
                radiusValue: 11.r,
                // width: 88.r,
                padding: EdgeInsets.symmetric(horizontal: 10.r),
              ),
              KqHeaderItemView(entity: KqFormEntity(title: '密码框展示')),
              KqPasswordView(
                isShowRightIcons: true,
                onChange: (value) {
                  KqToast.showNormal(value);
                },
              ),
              KqPasswordView(
                isShowRightIcons: true,
                rightIcons: [
                  Images.homeIcTouxiang,
                  Images.materialIcDelete16Red
                ],
              ),
              const KqPasswordView(),
              SizedBox(height: 50.r),
            ],
          ),
        ),

        bottomNavigationBar: KqBottomTabBar(
          icons: [
            Images.homeIcBanbenhao,
            Images.homeIcBanbenhao,
            Images.homeIcBanbenhao
          ],
          activeIcons: [
            Images.homeIcTouxiang,
            Images.homeIcTouxiang,
            Images.homeIcTouxiang
          ],
          titles: const ['首页', '工作台', '我的'],
          currentIndex: _selectedIndex,
          onTap: (value) {
            setState(() {
              _selectedIndex = value;
            });
            print(value);
          },
        ),
        // bottomNavigationBar: KqBottomTabBar(
        //   iconWidgets: [
        //     Image.asset(Images.homeIcBanbenhao),
        //     Image.asset(Images.homeIcBanbenhao),
        //     Image.asset(Images.homeIcBanbenhao)
        //   ],
        //   activeIconWidgets: [
        //     Image.asset(Images.homeIcTouxiang),
        //     Image.asset(Images.homeIcTouxiang),
        //     Image.asset(Images.homeIcTouxiang)
        //   ],
        //   titleWidgets: const [Text('首页'), Text('工作台'), Text('我的')],
        //   currentIndex: _selectedIndex,
        //   onTap: (value) {
        //     setState(() {
        //       _selectedIndex = value;
        //     });
        //     print(value);
        //   },
        // ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    Watcher().clear();
  }
}
